package cn.hp.crm.servlet.user;

import cn.hp.crm.service.UserService;
import cn.hp.crm.service.impl.UserServiceImpl;
import cn.hp.crm.util.JsonForServlet;
import cn.hp.crm.util.ResultData;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/demo.do")
public class DemoServlet extends HttpServlet {
    UserService userService = new UserServiceImpl();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

//        调用service层获取数据
        ResultData resultData = userService.selectTypeAndCount();
        JsonForServlet.transferData(response,resultData);
//        String name [] = { "java3","java4","java5","java6"};
//        int count [] = {44, 39, 37, 41};
//
//        Map map = new HashMap();
//        map.put("name", name);
//        map.put("count",count);
//
//        JsonForServlet.transferData(response, ResultData.getSuccessData("",map));
    }
}
